#!/usr/bin/env python3
# coding:utf-8
import requests
import json
server_url = 'http://0.0.0.0:8080/core/task/'
# server_url = 'http://0.0.0.0:8080/core/alarm/'


def test_add_task():
    data = {'name': "ck46", 'task_tpl':'123','task_type': '1',
            'start_time': '2018-07-30 01:01:01', 'end_time':'2018-07-31 12:12:12',
            'emergency_degree':1,'plan_workload':1,'device_id':2,
            'user_id':3, 'content':'检修20', 'tool':'大炮2'}
    url = server_url + 'add/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def test_add_alarm():
    data = {'grade': 1, 'alarm_time':'122','details': '超标',
            'pump_name': '1传感器1', 'device_name':'大炮',
            'monitoring': '18','reference': '20','type':1,}
    url = server_url + 'add/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def test_update_alarm():
    data = {'id': 1,'type': 6}
    url = server_url + 'update_alarm/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())



# test_add_task()
test_add_alarm()
# test_update_alarm()


if __name__ == '__main__':
    pass